#include <yatak/mutex.h>

bool mutex_enter(mutex_t *mutex/*, bool wait*/)
{
	bool old_value = true;
#ifdef __i386__
	do
	{
		asm("xchg (,%1,), %0":"=a"(old_value):"b"(mutex),"a"(old_value));
	}
	while (old_value/*&& wait*/);
#endif
	return !old_value;
}

void mutex_leave(mutex_t *mutex)
{
	*mutex = false;
}
